package com.shelpe.services.scheduler.step;

import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.shelpe.services.scheduler.po.SyncLog;
import com.shelpe.services.scheduler.po.Users;

@Configuration
public class CustomerStepConfiguration {

	 @Autowired
	 private StepBuilderFactory steps;
	 
	 @Bean 
	 public Step customerStep(@Qualifier("userReader") ItemReader<Users> reader,
			 @Qualifier("customerProcessor") ItemProcessor<Users, SyncLog> processor,
			 @Qualifier("userWriter") ItemWriter<SyncLog> writer){
 
		 return steps.get("customerStep")			 
						.<Users, SyncLog> chunk(1)
						.reader(reader)
						.processor(processor)
						.writer(writer)
						.faultTolerant()
						.retry(Exception.class)
						.retryLimit(6)
						.build();
	 }
}
